@extends('admin.layout')

@section('body')
    <div class="layui-layout layui-layout-admin">
        <!-- 头部 -->
        <div class="layui-header">
            <div class="layui-logo">
                {{--                <img src="/static/logo.png" style="height: 18px;width: 60px;"/>--}}
                {{\App\Facade\AppContext::appName()}}
            </div>
            <ul class="layui-nav layui-layout-left">
                <li class="layui-nav-item" lay-unselect>
                    <a ew-event="flexible" title="@lang('common.flexible')"><i
                                class="layui-icon layui-icon-shrink-right"></i></a>
                </li>
                <li class="layui-nav-item" lay-unselect>
                    <a ew-event="refresh" title="@lang('common.refresh')"><i
                                class="layui-icon layui-icon-refresh-3"></i></a>
                </li>
                <li class="layui-nav-item">
                    <div style="color: #0C0C0C">
                        今天登记<span style="color: red">{{$rd['d']}}</span>条。本周登记<span style="color: red">{{$rd['w']}}</span>条，本月登记<span style="color: red">{{$rd['m']}}</span>条，总登记<span style="color: red">{{$rd['a']}}</span>条。
                    </div>
                </li>
            </ul>

            <ul class="layui-nav layui-layout-right" style="margin-right: 20px;">
                @if(!empty(\App\Facade\AppContext::get('hospitals',[])))

                    <li class="layui-nav-item" lay-unselect>
                        <a>
                            <cite>{{\App\Facade\AppContext::get('hospital_name','')}}</cite>
                        </a>
                        <dl class="layui-nav-child">
                            @foreach(\App\Facade\AppContext::get('hospitals',[]) as $hospital)
                                <dd lay-unselect><a ew-event="hospital"
                                                    data-id="{{$hospital['id']}}">{{$hospital['name']}}</a></dd>
                            @endforeach
                        </dl>
                    </li>
                @else
                    <li class="layui-nav-item">
                        <a>
                            <cite>{{\App\Facade\AppContext::get('hospital_name','')}}</cite>
                        </a>
                    </li>
                @endif
                {{--                <li class="layui-nav-item" lay-unselect>--}}
                {{--                    <a ew-event="message" data-url="{{admin_url('index/message')}}" title="消息">--}}
                {{--                        <i class="layui-icon layui-icon-notice"></i>--}}
                {{--                        <span class="layui-badge-dot"></span>--}}
                {{--                    </a>--}}
                {{--                </li>--}}
                {{--                <li class="layui-nav-item" lay-unselect>--}}
                {{--                    <a ew-event="note" title="便签" data-url="{{admin_url('index/note')}}"><i--}}
                {{--                                class="layui-icon layui-icon-note"></i></a>--}}
                {{--                </li>--}}
                <li class="layui-nav-item layui-hide-xs" lay-unselect>
                    <a ew-event="fullScreen" title="@lang('common.full_screen')"><i
                                class="layui-icon layui-icon-screen-full"></i></a>
                </li>
                {{--                <li class="layui-nav-item layui-hide-xs" lay-unselect>--}}
                {{--                    <a ew-event="lockScreen" title="锁屏" data-url="{{admin_url('index/lock_screen')}}"><i--}}
                {{--                                class="layui-icon layui-icon-password"></i></a>--}}
                {{--                </li>--}}
                <li class="layui-nav-item" lay-unselect>
                    <a>
                        <img src="/static/nor.png" class="layui-nav-img">
                        <cite>{{\App\Facade\AppContext::userInfo('username','')}}</cite>
                    </a>
                    <dl class="layui-nav-child" style="left: auto;right: 0;">
                        {{--                        <dd lay-unselect><a ew-href="{{admin_url('index/userInfo')}}">个人中心</a></dd>--}}
                        <dd lay-unselect><a ew-event="psw"
                                            data-url="{{admin_url('index/password')}}">@lang('system.index.update_password')</a>
                        </dd>
                        <hr>
                        <dd lay-unselect><a ew-event="logout"
                                            data-title="@lang('common.tips.reminder')"
                                            data-content="@lang('common.tips.logout_tip')"
                                            data-url="{{admin_url('public/login')}}"
                            >@lang('common.logout')</a></dd>
                    </dl>
                </li>
{{--                                <li class="layui-nav-item" lay-unselect>--}}
{{--                                                        <a ew-event="theme" title="主题" data-url="{{admin_url('index/theme')}}"><i--}}
{{--                                                                    class="layui-icon layui-icon-more-vertical"></i></a>--}}
{{--                                    <a><i class="layui-icon layui-icon-more-vertical"></i></a>--}}
{{--                                </li>--}}
            </ul>

        </div>

        <!-- 侧边栏 -->
        <div class="layui-side">
            <div class="layui-side-scroll">
                <ul class="layui-nav layui-nav-tree arrow2" lay-filter="admin-side-nav" lay-shrink="_all">
                    {{--                    <li class="layui-nav-item">--}}
                    {{--                        <a><i class="layui-icon layui-icon-home"></i>&emsp;<cite>仪表板</cite></a>--}}
                    {{--                        <dl class="layui-nav-child">--}}
                    {{--                            <dd><a lay-href="{{admin_url('console/workplace')}}">工作台</a></dd>--}}
                    {{--                            <dd><a lay-href="{{admin_url('console')}}">控制台</a></dd>--}}
                    {{--                            <dd><a lay-href="{{admin_url('console/dashboard')}}">分析页</a></dd>--}}
                    {{--                        </dl>--}}
                    {{--                    </li>--}}
                    {!! widget_admin_menu() !!}
                </ul>
                {{--                <div style="text-align: center;color: white;width: 225px;">--}}
                {{--                    <div><img src="/admin/assets/images/qun.jpg" width="180"/></div>--}}
                {{--                    <span style="font-weight: bold;font-size: 16px;">酷蛙飞机群</span>--}}
                {{--                </div>--}}
            </div>
        </div>

        <!-- 主体部分 -->
        <div class="layui-body" style="bottom: 0px;"></div>
    </div>

    <!-- 加载动画 -->
    <div class="page-loading">
        <div class="ball-loader">
            <span></span><span></span><span></span><span></span>
        </div>
    </div>
@stop
@push('style')

@endpush
@push('script')
    <script src="/message.js"></script>
    <script>


        layui.use(['index', 'admin'], function () {
            var $ = layui.jquery;
            var index = layui.index;

            // 默认加载主页
            index.loadHome({
                menuPath: "{{admin_url('console')}}",
                menuName: '<i class="layui-icon layui-icon-home"></i>'
            });
            layui.admin.events.lang = function () {
                setLang($(this).data().id);
                layui.admin.closeAllTabs();
                location.reload();
            }

            layui.admin.events.hospital = function () {
                SystemUtil.ajax("{{admin_url('index/hospital')}}")
                    .setData({hospital_id: $(this).data().id})
                    .send(1)
                    .done((res) => {
                        layui.admin.closeAllTabs();
                        location.reload();
                    })
            }
            @if(!config('message.disable'))
            let message = new Message("{{config('message.web_socket_address')}}", 1);
            // var notice = layui.notice; // 允许别名 toastr
            // // 初始化配置，同一样式只需要配置一次，非必须初始化，有默认配置
            // notice.options = {
            //     closeButton: true,//显示关闭按钮
            //     debug: false,//启用debug
            //     positionClass: "toast-top-right",//弹出的位置,
            //     showDuration: "300",//显示的时间
            //     hideDuration: "300",//消失的时间
            //     timeOut: "5000",//停留的时间
            //     extendedTimeOut: "1000",//控制时间
            //     showEasing: "swing",//显示时的动画缓冲方式
            //     hideEasing: "linear",//消失时的动画缓冲方式
            //     iconClass: 'toast-info', // 自定义图标，有内置，如不需要则传空 支持layui内置图标/自定义iconfont类名
            //     onclick: null, // 点击关闭回调
            // };

            message.event.add("message", function (data, id) {
                // getUnReadNotice();
                console.log('event_message', data, id);
                switch (data.type) {
                    case 'register':
                        var audio1 = new Audio("/mp3/register.mp3");
                        audio1.play();//播放
                        break;

                    case 'card':
                        var audio1 = new Audio("/mp3/card.mp3");
                        audio1.play();//播放
                        break;

                    case 'message':
                        var audio1 = new Audio("/mp3/message.mp3");
                        audio1.play();//播放
                        break;
                }
            });
            message.connect();
            @endif
        });
    </script>
@endpush
